home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / listcol / frmlistc.frm (.txt) next >
Visual Basic Form  |  1998-10-19  |  3KB  |  82 lines

  1. VERSION 5.00
  2. Begin VB.Form frmListcol 
  3.    Caption         =   "Simulated Columns in a VB ListBox"
  4.    ClientHeight    =   3885
  5.    ClientLeft      =   3255
  6.    ClientTop       =   1785
  7.    ClientWidth     =   6045
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   259
  10.    ScaleMode       =   3  'Pixel
  11.    ScaleWidth      =   403
  12.    Begin VB.PictureBox Separator 
  13.       Appearance      =   0  'Flat
  14.       BackColor       =   &H80000005&
  15.       ForeColor       =   &H80000008&
  16.       Height          =   3375
  17.       Index           =   1
  18.       Left            =   2760
  19.       ScaleHeight     =   3345
  20.       ScaleWidth      =   345
  21.       TabIndex        =   2
  22.       Top             =   0
  23.       Width           =   375
  24.    End
  25.    Begin VB.PictureBox Separator 
  26.       Appearance      =   0  'Flat
  27.       BackColor       =   &H80000005&
  28.       ForeColor       =   &H80000008&
  29.       Height          =   3375
  30.       Index           =   0
  31.       Left            =   1800
  32.       ScaleHeight     =   3345
  33.       ScaleWidth      =   345
  34.       TabIndex        =   1
  35.       Top             =   0
  36.       Width           =   375
  37.    End
  38.    Begin VB.ListBox List1 
  39.       Height          =   3375
  40.       Left            =   240
  41.       TabIndex        =   0
  42.       Top             =   240
  43.       Width           =   5535
  44.    End
  45. Attribute VB_Name = "frmListcol"
  46. Attribute VB_GlobalNameSpace = False
  47. Attribute VB_Creatable = False
  48. Attribute VB_PredeclaredId = True
  49. Attribute VB_Exposed = False
  50.   Option Explicit
  51.   ' demo project showing how to set tabstops to simulate virtical
  52.   ' columns in a listbox using the SendMessage API function
  53.   ' by Bryan Stafford of New Vision Software
  54.  - newvision@imt.net
  55.   ' this demo is released into the public domain "as is" without
  56.   ' warranty or guaranty of any kind.  In other words, use at
  57.   ' your own risk.
  58.   ' the constant we use when telling the listbox where to set the tabstops
  59.   Private Const LB_SETTABSTOPS As Long = &H192&
  60.   Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd&, _
  61.                                                     ByVal wMsg&, ByVal wParam&, lParam As Any)
  62. Private Sub Form_Load()
  63.   ' move the picture boxes used for column seperators into place over top of the list box
  64.   Separator(False).Move List1.Left + ((List1.Width - 4) \ 3), List1.Top + 2, 1, _
  65.                                                                     List1.Height - 4
  66.   Separator(1).Move List1.Left + ((List1.Width - 4) - ((List1.Width - 4) \ 3)), _
  67.                                                   List1.Top + 2, 1, List1.Height - 4
  68.   ReDim TabStops(1) As Long ' this dimentions the array to two items, 0 and 1
  69.   TabStops(0) = 82  ' First Tab stop position
  70.   TabStops(1) = 163     ' Second Tab position
  71.   ' tab widths are figured in "dialog units" which are approxemately
  72.   ' 1/4 of the width of the average charactor in the currently selected font.
  73.   Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 2&, TabStops(0))
  74.   ' 2& = number of tabs being set, TabStops(0) is first array element
  75.   Dim i%
  76.   ' add some items to the listbox
  77.   For i = 1 To 50
  78.     List1.AddItem "Item " & CStr(i) & " Column 1" & vbTab & "Item " & CStr(i) & " Column 2" & _
  79.                                                          vbTab & "Item " & CStr(i) & " Column 3"
  80.   Next
  81. End Sub
  82.